import { defHttp } from '@/utils/http/axios';
import {
  AppidBindData,
  IOpenShop,
  IOpenShopDetail,
  IShopInfo,
  InstitutionList,
  MemberMerchant,
} from './type';
import { BasicFetchResult } from '@/api/model/baseModel';

enum Api {
  /**商户平台管理列表 */
  getShopInfoList = '/mall/op/merchant/org/list',
  /**获取机构下拉框列表 */
  getInstitutionList = '/admin/org-basics-info/getInfoList',
  /**开通店铺 */
  saveShop = '/mall/op/shop/addOpShop',
  /**查询开通店铺详情 */
  getOpenShopDetail = '/mall/op/shop/getInfo',
  /** 修改店铺*/
  updateShop = '/mall/op/shop/updateShop',

  /**支付绑定 */
  bindAppid = '/mall/op/merchant/org/bind',
  getMemberMerchantList = '/mall/op/merchant/member/list',
}

/**
 * 商户平台管理
 * @param params
 * @returns
 */
export function getShopInfoList(params) {
  return defHttp.get<BasicFetchResult<IShopInfo>>({
    url: Api.getShopInfoList,
    params,
  });
}

/**
 * 会员商户号
 * @param params
 * @returns
 */
export function getMemberMerchantList(params) {
  return defHttp.get<BasicFetchResult<MemberMerchant>>({
    url: Api.getMemberMerchantList,
    params,
  });
}

/**
 * 获取机构下拉框列表
 * @param params
 * @returns
 */
export function getInstitutionList(params) {
  return defHttp.get<InstitutionList[]>({
    url: Api.getInstitutionList,
    params,
  });
}

/**
 * 开通店铺
 * @param data
 * @returns
 */
export function saveShop(data: IOpenShop) {
  return defHttp.post({
    url: Api.saveShop,
    data,
  });
}

/**
 * 修改店铺
 * @param data
 * @returns
 */
export function updateShop(data: IOpenShop) {
  return defHttp.post({
    url: Api.updateShop,
    data,
  });
}

/**
 * 查询开通店铺详情
 * @param tenantId
 * @returns
 */
export function getOpenShopDetail(tenantId: number) {
  return defHttp.get<IOpenShopDetail>({
    url: Api.getOpenShopDetail + '/' + tenantId,
  });
}

/**
 * 支付绑定
 * @param tenantId
 * @returns
 */
export function bindAppid(params: AppidBindData) {
  return defHttp.get({
    url: Api.bindAppid,
    params,
  });
}
